package io.wdb.modules.generator.generator.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.wdb.modules.generator.generator.entity.UserMaintainLogEntity;
import io.wdb.modules.generator.generator.service.UserMaintainLogService;
import io.wdb.common.utils.PageUtils;
import io.wdb.common.utils.Query;
import io.wdb.common.utils.R;


/**
 * 
 * 
 * @author wdb
 * @email admin@wdb007.com
 * @date 2018-03-15 14:09:32
 */
@RestController
@RequestMapping("usermaintainlog")
public class UserMaintainLogController {
	@Autowired
	private UserMaintainLogService userMaintainLogService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("usermaintainlog:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<UserMaintainLogEntity> userMaintainLogList = userMaintainLogService.queryList(query);
		int total = userMaintainLogService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(userMaintainLogList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{userId}")
	@RequiresPermissions("usermaintainlog:info")
	public R info(@PathVariable("userId") String userId){
		UserMaintainLogEntity userMaintainLog = userMaintainLogService.queryObject(userId);
		
		return R.ok().put("userMaintainLog", userMaintainLog);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("usermaintainlog:save")
	public R save(@RequestBody UserMaintainLogEntity userMaintainLog){
		userMaintainLogService.save(userMaintainLog);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("usermaintainlog:update")
	public R update(@RequestBody UserMaintainLogEntity userMaintainLog){
		userMaintainLogService.update(userMaintainLog);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("usermaintainlog:delete")
	public R delete(@RequestBody String[] userIds){
		userMaintainLogService.deleteBatch(userIds);
		
		return R.ok();
	}
	
}
